home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 4 / QRZ Ham Radio Callsign Database - Volume 4.iso / files / tcpip / amiga / asrc29p.lha / global.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-29  |  5.4 KB  |  202 lines

  1. #ifndef    MAXINT16
  2.  
  3. /* Global definitions used by every source file.
  4.  * Some may be compiler dependent.
  5.  */
  6.  
  7. #if    defined(__TURBOC__) || defined(__STDC__) || defined(LATTICE)
  8. #define    ANSIPROTO    1
  9. #endif
  10.  
  11. #ifndef    TRUE
  12. #define    TRUE    1
  13. #endif
  14. #ifndef    FALSE
  15. #define    FALSE    0
  16. #endif
  17.  
  18. #ifndef    __ARGS
  19. #ifdef    ANSIPROTO
  20. #define    __ARGS(x)    x
  21. #else
  22. #define    __ARGS(x)    ()
  23. #endif
  24. #endif
  25.  
  26.  
  27. #if    !defined(AMIGA) && (defined(LATTICE) || defined(MAC) || defined(__TURBOC__))
  28. /* These compilers require special open modes when reading binary files.
  29.  * 
  30.  * "The single most brilliant design decision in all of UNIX was the
  31.  * choice of a SINGLE character as the end-of-line indicator" -- M. O'Dell
  32.  *
  33.  * "Whoever picked the end-of-line conventions for MS-DOS and the Macintosh
  34.  * should be shot!" -- P. Karn's corollary to O'Dells' declaration
  35.  */
  36. #define    READ_BINARY    "rb"
  37. #define    WRITE_BINARY    "wb"
  38. #define    READ_TEXT    "rt"
  39. #define    WRITE_TEXT    "wt"
  40. #define    APPEND_TEXT    "at+"
  41.  
  42. #else
  43.  
  44. #define    READ_BINARY    "r"
  45. #define    WRITE_BINARY    "w"
  46. #define    READ_TEXT    "r"
  47. #define    WRITE_TEXT    "w"
  48. #define    APPEND_TEXT    "a+"
  49.  
  50. #endif
  51.  
  52. /* These two lines assume that your compiler's longs are 32 bits and
  53.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  54.  * but it doesn't matter if they're signed or unsigned.
  55.  */
  56. typedef long int32;        /* 32-bit signed integer */
  57. typedef unsigned short int16;    /* 16-bit unsigned integer */
  58. #define    uchar(x) ((unsigned char)(x))
  59. #define    MAXINT16 65535        /* Largest 16-bit integer */
  60. #define    MAXINT32 4294967295L    /* Largest 32-bit integer */
  61.  
  62. /* The "interrupt" keyword is non-standard, so make it configurable */
  63. #ifdef    __TURBOC__
  64. #define    INTERRUPT    void interrupt
  65. #else
  66. #define    INTERRUPT    void
  67. #endif
  68.  
  69. /* Note that these definitions are on by default if none of the Turbo-C style
  70.  * memory model definitions are on; this avoids having to change them when
  71.  * porting to 68K environments.
  72.  */
  73. #if    !defined(__TINY__) && !defined(__SMALL__) && !defined(__MEDIUM__)
  74. #define    LARGEDATA    1
  75. #endif
  76.  
  77. #if    !defined(__TINY__) && !defined(__SMALL__) && !defined(__COMPACT__)
  78. #define    LARGECODE    1
  79. #endif
  80.  
  81. /* Since not all compilers support structure assignment, the ASSIGN()
  82.  * macro is used. This controls how it's actually implemented.
  83.  */
  84. #ifdef    NOSTRUCTASSIGN    /* Version for old compilers that don't support it */
  85. #define    ASSIGN(a,b)    memcpy((char *)&(a),(char *)&(b),sizeof(b));
  86. #else            /* Version for compilers that do */
  87. #define    ASSIGN(a,b)    ((a) = (b))
  88. #endif
  89.  
  90. /* Define null object pointer in case stdio.h isn't included */
  91. #ifndef    NULL
  92. /* General purpose NULL pointer */
  93. #define    NULL (void *)0
  94. #endif
  95. #define    NULLCHAR (char *)0    /* Null character pointer */
  96. #define    NULLCHARP (char **)0    /* Null character pointer pointer */
  97. #define    NULLINT    (int *)0    /* Null integer pointer */
  98. #define    NULLFP     (int (*)())0    /* Null pointer to function returning int */
  99. #define    NULLVFP     (void (*)())0    /* Null pointer to function returning void */
  100. #define    NULLVIFP (INTERRUPT (*)())0
  101. #define    NULLFILE (FILE *)0    /* Null file pointer */
  102.  
  103. /* Extract a short from a long */
  104. #define    hiword(x)    ((int16)((x) >> 16))
  105. #define    loword(x)    ((int16)(x))
  106.  
  107. /* Extract a byte from a short */
  108. #define    hibyte(x)    ((unsigned char)((x) >> 8))
  109. #define    lobyte(x)    ((unsigned char)(x))
  110.  
  111. /* Extract nibbles from a byte */
  112. #define    hinibble(x)    (((x) >> 4) & 0xf)
  113. #define    lonibble(x)    ((x) & 0xf)
  114.  
  115. /* Various low-level and miscellaneous functions */
  116. unsigned long availmem __ARGS((void));
  117. void *callocw __ARGS((unsigned nelem,unsigned size));
  118. int dirps __ARGS((void));
  119. void freeargs __ARGS((int argc,char *argv[]));
  120. int getopt __ARGS((int argc,char *argv[],char *opts));
  121. int htoi __ARGS((char *));
  122. long htol __ARGS((char *));
  123. char *inbuf __ARGS((int16 port,char *buf,int16 cnt));
  124. void mainlog __ARGS((int s,char *fmt, ...));
  125. void *ltop __ARGS((long));
  126. void *mallocw __ARGS((unsigned nb));
  127. char *outbuf __ARGS((int16 port,char *buf,int16 cnt));
  128. long ptol __ARGS((void *));
  129. void restore __ARGS((int));
  130. void rip __ARGS((char *));
  131. char *smsg __ARGS((char *msgs[],unsigned nmsgs,unsigned n));
  132. int tprintf __ARGS((char *fmt,...));
  133. #if    !defined __TURBOC__
  134. char *strdup __ARGS((const char *));
  135. #endif
  136. int wildmat __ARGS((char *s,char *p,char **argv));
  137.  
  138. #include <stdlib.h>
  139. #include <string.h>
  140.  
  141. #ifdef    AZTEC
  142. #define    rewind(fp)    fseek(fp,0L,0);
  143. #endif
  144.  
  145. #ifdef    __TURBOC__
  146. #define movblock(so,ss,do,ds,c)    movedata(ss,so,ds,do,c)
  147. #define outportw outport
  148. #define inportw inport
  149.  
  150. #else
  151.  
  152. /* General purpose function macros already defined in turbo C */
  153. #ifndef    min
  154. #define    min(x,y)    ((x)<(y)?(x):(y))    /* Lesser of two args */
  155. #endif
  156. #ifndef max
  157. #define    max(x,y)    ((x)>(y)?(x):(y))    /* Greater of two args */
  158. #endif
  159. #ifdef    MSDOS
  160. #define MK_FP(seg,ofs)    ((void far *) \
  161.                (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  162. #endif
  163. #endif    /* __TURBOC __ */
  164.  
  165. #ifdef    AMIGA
  166. /* super kludge de WA3YMH */
  167. #ifndef    fileno
  168. #include <stdio.h>
  169. #endif
  170. #define fclose(fp)    amiga_fclose(fp)
  171. extern int amiga_fclose __ARGS((FILE *));
  172. extern FILE *tmpfile __ARGS((void));
  173.  
  174. extern char *sys_errlist[];
  175. extern int errno;
  176. #endif
  177.  
  178. /* Externals used by getopt */
  179. extern int optind;
  180. extern char *optarg;
  181.  
  182. /* Threshold setting on available memory */
  183. extern int32 Memthresh;
  184.  
  185. /* System clock - count of ticks since startup */
  186. extern int32 Clock;
  187.  
  188. /* Various useful standard error messages */
  189. extern char Badhost[];
  190. extern char Badinterface[];
  191. extern char Nospace[];
  192. extern char Notval[];
  193. extern char *Hostname;
  194. extern char Version[];
  195. extern char Mversion[];
  196. extern char Aversion[];
  197.  
  198. #endif    /* MAXINT16 */
  199.  
  200. #define    LINELEN        256
  201. #define    SLINELEN    64
  202.